﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.Election.DecisionOutcome
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.Election
{
  public abstract class DecisionOutcome
  {
    [SaveableField(0)]
    public float InitialMerit;
    [SaveableField(1)]
    public List<Supporter> SupporterList = new List<Supporter>();
    [SaveableField(2)]
    private Clan _sponsorClan;

    protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      collectedObjects.Add((object) this.SupporterList);
      collectedObjects.Add((object) this._sponsorClan);
    }

    internal static object AutoGeneratedGetMemberValueInitialMerit(object o)
    {
      return (object) ((DecisionOutcome) o).InitialMerit;
    }

    internal static object AutoGeneratedGetMemberValueSupporterList(object o)
    {
      return (object) ((DecisionOutcome) o).SupporterList;
    }

    internal static object AutoGeneratedGetMemberValue_sponsorClan(object o)
    {
      return (object) ((DecisionOutcome) o)._sponsorClan;
    }

    public float Support
    {
      get
      {
        float support = 0.0f;
        foreach (Supporter supporter in this.SupporterList)
        {
          switch (supporter.SupportWeight)
          {
            case Supporter.SupportWeights.SlightlyFavor:
              support += 0.2f;
              continue;
            case Supporter.SupportWeights.StronglyFavor:
              support += 0.4f;
              continue;
            case Supporter.SupportWeights.FullyPush:
              ++support;
              continue;
            default:
              continue;
          }
        }
        return support;
      }
    }

    public float Merit => this.InitialMerit * (1f + this.Support);

    public Clan SponsorClan => this._sponsorClan;

    public float InitialSupport { get; internal set; }

    public float Likelihood { get; internal set; }

    public float TotalSupportPoints { get; internal set; }

    public float WinChance { get; internal set; }

    public abstract TextObject GetDecisionTitle();

    public abstract TextObject GetDecisionDescription();

    public abstract string GetDecisionLink();

    public abstract ImageIdentifier GetDecisionImageIdentifier();

    public void AddSupport(Supporter supporter) => this.SupporterList.Add(supporter);

    public void ResetSupport(Supporter supporter)
    {
      if (!this.SupporterList.Contains(supporter))
        return;
      this.SupporterList.Remove(supporter);
    }

    public void SetSponsor(Clan sponsorClan) => this._sponsorClan = sponsorClan;
  }
}
